/*
 * WhileInstruction.h
 *
 *  Created on: 29/dic/2010
 *      Author: computer
 */

#ifndef WHILEINSTRUCTION_H_
#define WHILEINSTRUCTION_H_
#include "Expression.h"
#include "FlowExpression.h"

namespace TreeExpression {

class WhileInstruction : public FlowExpression, public Expression_CRTP<WhileInstruction> {
public:
	WhileInstruction();
	WhileInstruction(const WhileInstruction&);
	~WhileInstruction();

	void setCondition(const AutoPointer<Expression>&);
	void addInstruction(const AutoPointer<Expression>&);

	Expression* clone() const;

	virtual AutoPointer<Expression> eval(CopyPointer<Context>&);
	virtual std::string toString() const;

	virtual bool isStop() const;
private:
	std::list< AutoPointer<Expression> > cloneInstruction() const;

	bool stop;
	AutoPointer<Expression> condition;
	std::list< AutoPointer<Expression> > listInstruction;
};

}

#endif /* WHILEINSTRUCTION_H_ */
